package Registration;

import java.sql.ResultSet;
import dbmanager.DBManager;

public class DeleteUnReferencedprop 
{
	DeleteUnReferencedprop()
	{
		DBManager db = new DBManager();
		db.getConnect();
		ResultSet rs = db.getSelect("Select max(id) x from master_table");
		try
		{
			rs.next();
			long index = Long.parseLong(rs.getString(1));
			for(long i= 1; i<=index;i++)
			{
				try 
				{
					ResultSet MasterRS = db.getSelect("Select id from master_table where id = "+i);
					MasterRS.next();
					@SuppressWarnings("unused")
					long MasterIndex = Long.parseLong(MasterRS.getString(1));
				}
				catch (Exception e) {
				//	e.printStackTrace();
					db.getDelete("delete from property_details where mid="+i+" or pid="+i+" or ref="+i);
				}
			}
		} 
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static void main(String [] a)
	{
		new DeleteUnReferencedprop();
	}
}
